<?php 

class Utils_DocReadyScript {
	private $view = null;
	private $scripts = null;
	
	public function __construct(Zend_View_Interface $view) {
		$this->view = $view;
		$this->scripts = array();
	}

	public function add($script) {
		array_push($this->scripts, $script);
	}
	
	public function toString() {
		$javascript = '';
		if (count($this->scripts) > 0) {
			$javascript = '<script type="text/javascript">$(document).ready(function() {';
			foreach ($this->scripts as $script) {
				$javascript .= $script;
			}
			$javascript .= '})</script>';
		}
		return (string) $javascript;
	}
	
    public function __toString() {
        return $this->toString();
    }
}